package com.xjtu.common.api;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;


/**
 * API统一响应基类
 */
@ApiModel(value = "response", description = "统一响应基类")
@Data
public class Result {

    @ApiModelProperty(value = "状态码", dataType = "int", example = "1")
    private int code;

    @ApiModelProperty(value = "描述信息", dataType = "String", example = "成功")
    private String msg;

    @ApiModelProperty(value = "返回数据", dataType = "Object", example = "null")
    private Object data;


    public Result() {
        this.code = ResultCode.OK.getCode();
        this.msg = ResultCode.OK.getMsg();
    }

    public Result(ResultCode resultCode) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
    }

    public Result(Object data) {
        this.code = ResultCode.OK.getCode();
        this.msg = ResultCode.OK.getMsg();
        this.data = data;
    }

    public Result(ResultCode resultCode, Object body) {
        this(body);
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
    }
}
